import HTTP from '@/libs/http'

class InitApi extends HTTP {
  /**
   * @description: 字典项
   * @author llx
   * @date 2021.03.03
   */

  init({ type }) {
    return this.request({
      method: 'GET',
      url: '/smart/smart-app/dic/init',
      params: { type }
    })
  }
}

class UserApi extends HTTP {
  /**
   * @description: 验证码校验
   * @author lsr
   * @date 2021.03.04
   * @param {String} loginName 用户名
   */
  sendCode({ loginName }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/validatecode',
      data: { loginName }
    })
  }

  /**
   * @description: 发送用户定位
   * @author lsr
   * @date 2021.06.30
   * @param {String} longitude 经度
   * @param {String} latitude 维度
   */
  sendLocation({ longitude, latitude }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/location/save',
      data: { longitude, latitude }
    })
  }

  /**
   * @description: 发送用户定位
   * @author cx
   * @date 2021.10.28
   * @param {String} longitude 经度
   * @param {String} latitude 维度
   * @param {String} appCode
   * @param {String} gridCode
   * @param {String} regionCode
   * @param {String} phone
   * @param {String} communityCode
   * @param {String} gridPersonType
   * @param {String} gridName
   * @param {String} gridPersonCode
   * @param {String} gridPersonName
   */
  positioningLocation({
    longitude,
    latitude,
    appCode,
    gridCode,
    regionCode,
    phone,
    gridPersonType,
    gridName,
    gridPersonCode,
    gridPersonName
  }) {
    return this.request({
      method: 'POST',
      url: '/smart/smart-app/user/location/create',
      data: {
        longitude,
        latitude,
        appCode,
        gridCode,
        regionCode,
        phone,
        gridPersonType,
        gridName,
        gridPersonCode,
        gridPersonName
      }
    })
  }
}

class PublicClass {
  constructor() {
    this.Init = new InitApi()
    this.User = new UserApi()
  }
}

const Public = new PublicClass()

export default Public
